package com.hmkj.core.mapper.announce;

import com.hmkj.common.baseMapper.GenericMapper;
import com.hmkj.core.po.announce.Announce;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * 系统公告表相关Dao接口<br>
 *
 * @author lizhijie
 * @date   2018-07-04 03:31:43
 */
public interface AnnounceMapper extends GenericMapper< Announce,Integer> {

    /**
     * 前台获取公告列表
     * @param params
     * @return
     */
    @Select(" <script> SELECT COUNT(1) FROM biz_announce t WHERE t.del_flag = 1 AND t.status = #{status}" +
            "<if test=\"agentId != null and agentId != '' \"> AND t.`agent_id` in (0,#{agentId}) </if>" +
            "<if test=\"agentId == null or agentId == '' \"> AND t.`agent_id` in (0) </if>" +
            " ORDER BY t.release_time DESC </script>")
    Integer findCountForAnnounceList(Map<String, Object> params);

    /**
     * 前台获取公告列表
     */
    @Select(" <script> SELECT t.* FROM biz_announce t WHERE t.del_flag = 1 AND t.status = #{status}" +
            "<if test=\"agentId != null and agentId != '' \"> AND t.`agent_id` in (0,#{agentId}) </if>" +
            "<if test=\"agentId == null or agentId == '' \"> AND t.`agent_id` in (0) </if>" +
            " ORDER BY t.release_time DESC </script>")
    List<Announce> findListForAnnounceList(Map<String, Object> params);

}
